package com.example.jksj.bookmanagement.pro.mine.activity;

import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;

import com.example.jksj.bookmanagement.R;
import com.example.jksj.bookmanagement.pro.home.adapter.BookAdapter;
import com.example.jksj.bookmanagement.bean.BookBean;
import com.example.jksj.bookmanagement.common.MyActivity;

import java.util.ArrayList;
import java.util.List;

public class MyCollectionActivity extends MyActivity {

    private RecyclerView mRecyclerView;
    private List<BookBean> collectionBookList;
    private StaggeredGridLayoutManager recyclerViewLayoutManager;
    private BookAdapter bookAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_collection;
    }

    @Override
    protected int getTitleBarId() {
        return R.id.tb_title_MyCollection;
    }

    @Override
    protected void initView() {
        mRecyclerView = findViewById(R.id.recycler_MyCollection);
        //使用瀑布流布局,第一个参数 spanCount 列数,第二个参数 orentation 排列方向
        recyclerViewLayoutManager = new StaggeredGridLayoutManager(3,
                StaggeredGridLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(recyclerViewLayoutManager);

    }

    @Override
    protected void initData() {
        setHotBooks();
        bookAdapter = new BookAdapter(collectionBookList);
        mRecyclerView.setAdapter(bookAdapter);
    }

    public void setHotBooks(){
        collectionBookList = new ArrayList<BookBean>(24);
        collectionBookList.add(new BookBean("莫失莫忘","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1537322934.jpg"));
        collectionBookList.add(new BookBean("十一种孤独","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512707236.jpg"));
        collectionBookList.add(new BookBean("火星纪事","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512707205.jpg"));
        collectionBookList.add(new BookBean("双重赔偿","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512706913.jpg"));
        collectionBookList.add(new BookBean("流动的盛宴","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512706668.jpg"));
        collectionBookList.add(new BookBean("莫失莫忘","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1537322934.jpg"));
        collectionBookList.add(new BookBean("十一种孤独","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512707236.jpg"));
        collectionBookList.add(new BookBean("火星纪事","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512707205.jpg"));
        collectionBookList.add(new BookBean("双重赔偿","http://e.library.sh.cn/wread2017/_cover/shyw/ShlibEpub_1512706913.jpg"));
    }
}
